|
|
|
|
|
|
|
|
Most of the time, you need to make the EXE project the Startup Project. Other controls and DLLs are started also, but only the Startup Project receives the focus.  |
|
|
|
|
|
|
|
|
|
|
Using Multiple Instances of VB |
|
|
|
|
|
|
|
|
Sometimes using multiple instances of VB is more convenient than using a project group. If you have very complex EXE and DLL projects, using multiple instances may be a better option because you can look at each project in its own environment. The main difference is that with a project group, Visual Basic handles starting and stopping all the projects. With multiple instances of Visual Basic, you manually have to start the projects needed by a given project. In other words, you first start the ActiveX DLL project and then start the Standard EXE project. |
|
|
|
|
|
|
|
|
All the debugging features are still available between multiple instances of VB. In other words, you can set breakpoints and step back and forth between code in both projects. However, since additional inter-process communication is involved between multiple instances of Visual Basic, you may have to restart projects more often than you would when using a project group. |
|
|
|
|
|
|
|
|
Using a compiled ActiveX DLL requires only a single open instance of Visual Basic. This is not a method for testing code within a class because you cannot use any of the debugging features. However, another developer can use a compiled DLL on his or her machine without having to copy your project and code. Using a compiled DLL involves a few simple steps: |
|
|
|
|
|
|
|
|
1. Installation. Copy the DLL and any components or files it needs to the developer's PC. |
|
|
|
|
|
|
|
|
2. Register the DLL. Use the REGSVR32 program to register the DLL in the Windows registry. |
|
|
|
|
|
|
|
|
3. Reference the DLL. After the DLL is installed and registered on a machine, it should appear in the References Dialog in Visual Basic. |
|
|
|
|
|
|
|
|
Referencing and Using the DLL |
|
|
|
|
|
|
|
|
No matter which method you use to load an ActiveX DLL project (project group, multiple VB instances, compiled DLL), you always must reference the DLL in your Standard EXE project. Display the References dialog box by choosing References from Visual Basic's Project menu. The list of Available References should contain the project name of your ActiveX DLL. After you place a check mark in the box next to the ActiveX DLL name, it is available to the current project. |
|
|
|
|
|
|
|
|
|
When using multiple instances of VB, you may have to rereference a DLL after you make changes to it. Also, the ActiveX DLL project does not show up in the References dialog box until the project is started.  |
|
|
|
|
|
|
|
|
|
|
In the earlier example, you created a new instance of the employee object by simply naming the class: |
|
|
|
|
|
|
|
|
Dim objBoss As New clsEmployee |
|
|
|
|
|
|
|
|
However, when the class is defined in another compiled ActiveX component, you also have to include the project name: |
|
|
|
|
|
|
|
|
Dim objBoss As New EmployeeDLL.clsEmployee |
|
|
|
|
|